package com.shop.listener;

import com.alibaba.otter.canal.protocol.CanalEntry;
import com.shop.config.RabbitConfig;
import com.xpand.starter.canal.annotation.CanalEventListener;
import com.xpand.starter.canal.annotation.ListenPoint;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.client.RestTemplate;

@CanalEventListener
public class AdListener {
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @ListenPoint(schema = "itbuka_ad",table = "ad")
    public void adUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData){
       rabbitTemplate.convertAndSend(RabbitConfig.AD_EXCHANGE,RabbitConfig.AD_QUEUE,1);
    }
}
